package study.ttl.mapper;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import study.ttl.entity.User;

import java.util.List;

@Mapper
public interface UserMapper {
    //根据用户名查询用户
    @Select("select * from user where username = #{username}")
    User selectByUsername(String username);

    //注册用户
    void insert(User user);

    // 根据id删除用户
    @Delete("delete from user where id = #{id}")
    void deleteById(Integer id);

    // 根据id修改用户
    void updateById(User user);

    // 根据id查询用户
    @Select("select * from user where id = #{id}")
    User selectById(Integer id);

    // 根据条件查询所有用户
    List<User> selectAll(User user);

    // 根据id批量删除用户
    void deleteBatch(List<Integer> ids);

    // 根据用户名修改用户密码
    @Update("update user set password = #{newPassword} where username = #{username}")
    void updatePassword(User dbUser);
}
